package cn.zhl.algorithm._1_排序;

/**
 * @program: demos
 * @description:
 * @author: 刘振华
 * @create: 2020-05-27 12:50
 **/
public class BubbleSort extends Sort{
	@Override
	protected void sort() {
		for(int i = array.length - 1; i>0;i--){
			int sortIndex = 1;
			for(int j = 0; j< i;j++){
//				if(array[j]>array[j+1]){
				if(compare(j,j+1)>0){
					swap(j,j+1);
					sortIndex = j+1;
				}
			}
			i = sortIndex;
		}
	}
}
